<?php
/** 
 * EGP Framework
 *
 * LICENSE
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author     Akon(番茄红了) <aultoale@gmail.com>
 * @copyright  Copyright (c) 2008 (http://www.tblog.com.cn)
 * @license    http://www.gnu.org/licenses/gpl.html     GPL 3
 */

!defined('EGP_LIB_DIR') && die('Access Deny!');

/**
 * 载入编辑器抽像类
 */
require_once('Editor/Abstract.php');

/**
 * HTML 编辑器封装
 *
 * @package    helper
 * @author     Akon(番茄红了) <aultoale@gmail.com>
 * @copyright  Copyright (c) 2008 (http://www.tblog.com.cn)
 * @license    http://www.gnu.org/licenses/gpl.html     GPL 3
 */
class EGP_View_Helper_Editor extends EGP_View_Helper_Abstract
{

    /**
     * 初始化方法
     *
     * @param  string  $adapter
     * @param  array   $config
     * @return EGP_View_Helper_Editor_Abstract
     * @throws EGP_Exception
     */
    public function init($adapter, array $config = array())
    {
        $editor = $this->view->callHelper('Editor_' . ucfirst($adapter), array($config));

        if (!$editor instanceof EGP_View_Helper_Editor_Abstract) {
            throw new EGP_Exception('无效的编辑器 Helper');
        }

        return $editor;
    }

}